package com.diaohw.module.system.obj.entity;

import com.diaohw.platform.framework.db.flex.obj.model.BaseModel;
import com.diaohw.platform.remote.auth.enums.AccountStateEnum;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.io.Serial;
import java.io.Serializable;

/**
 * 用户 实体类。
 *
 * @author D-Hw
 * @since 2024-11-15 18:22:15
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Schema(description = "用户")
@Table("ACCOUNT")
public class Account extends BaseModel implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 账号
     */
    @Column("USERNAME")
    @Schema(description = "账号")
    private String username;

    /**
     * 密码
     */
    @Column("PASSWORD")
    @Schema(description = "密码")
    private String password;

    /**
     * 加密盐值
     */
    @Column("SALT")
    @Schema(description = "加密盐值")
    private String salt;

    /**
     * 昵称
     */
    @Column("NICKNAME")
    @Schema(description = "昵称")
    private String nickname;

    /**
     * 邮箱
     */
    @Column("EMAIL")
    @Schema(description = "邮箱")
    private String email;

    /**
     * 联系方式
     */
    @Column("CONTACT")
    @Schema(description = "联系方式")
    private String contact;

    /**
     * 头像;对应文件服务的ID
     */
    @Column("AVATAR")
    @Schema(description = "头像;对应文件服务的ID")
    private String avatar;

    /**
     * 备注
     */
    @Column("REMARK")
    @Schema(description = "备注")
    private String remark;

    /**
     * 状态;状态，0：禁用，1：启用，2：锁定
     */
    @Column("STATE")
    @Schema(description = "状态;状态，0：禁用，1：启用，2：锁定")
    private Integer state;

    /**
     * 部门ID
     */
    @Column("DEPARTMENT_ID")
    @Schema(description = "部门ID")
    private String departmentId;

    public AccountStateEnum stateEnum() {
        return AccountStateEnum.parse(this.state);
    }

}
